package com.my.collection.stack.v4;

import java.util.concurrent.atomic.AtomicBoolean;

/**
 * Created by ZhongGang
 * at 2018/7/26 9:50
 */
public class Lock {
    private AtomicBoolean locked = new AtomicBoolean(false);

    public void lock() {
        while (!locked.compareAndSet(false, true)) {

        }
    }

    public void unlock() {
        this.locked.set(false);
    }
}
